<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use Hyperf\Database\Seeders\Seeder;

class InitSeed extends Seeder
{
    use \App\Traits\PwdTool;
    /**
     * Run the database seeds.
     */
    public function run()
    {
        \App\Model\Admin::truncate();
        \App\Model\Admin::create([
            'user_name' => '超级管理员_01',
            'login_name' => 'admin',
            'password' => $this->makePassword('smkj1324'),
            'avatar' => \Hyperf\Support\env('HOST_NAME') . '/upload/icon/user_avatar.jpg',
            'role_id' => 1,
        ]);

        \App\Model\Role::truncate();
        \App\Model\Role::create([
           'id' => 1,
           'role_name' => '超级管理员',
            'state' => 1,
            'role_en' => 'supplier'
        ]);

        \App\Model\Role::create([
            'id' => 2,
            'role_name' => '管理员',
            'state' => 1,
            'role_en' => 'supplier'
        ]);


        \App\Model\Setting::truncate();
        \App\Model\Setting::create([
            'id' => 1,
            'title' => '是否自动值守',
            'conf' => 2
        ]);

        \App\Model\CardNo::truncate();
        for ($i = 0; $i < 200; $i++) {

            \App\Model\CardNo::create([
                'card_no' => time() + $i
            ]);
        }
        \App\Model\Mobile::truncate();
        for ($i = 0; $i < 200; $i++) {

            \App\Model\Mobile::create([
                'mobile_area_en' => 'china',
                'mobile_area' => '+86',
                'mobile' => '186530' . (string)rand(10000, 99999),
            ]);
        }

        \App\Model\MobileArea::truncate();
        foreach ($this->getAreaArr() as $v) {
            \App\Model\MobileArea::create([
                'mobile_area_en' => $v['country'],
                'mobile_area' => $v['code']
            ]);
        }

        \App\Model\SmsCode::truncate();
        for ($i = 0; $i < 200; $i++) {
            if ($i % 2 == 0){

                \App\Model\SmsCode::create([
                    'mobile_area_en' => 'china',
                    'mobile_area' => '+86',
                    'mobile' => '186530' . (string)rand(10000, 99999),
                    'code' => (string)rand(10000, 99999),
                    'is_send' => 1
                ]);
            }else{
                \App\Model\SmsCode::create([
                    'mobile_area_en' => 'china',
                    'mobile_area' => '+86',
                    'mobile' => '186530' . (string)rand(10000, 99999),
                    'code' => '',
                    'is_send' => 2
                ]);
            }
        }
    }

    public function getAreaArr() {

        $string = "[{\"country\": \"Afghanistan\", \"code\": \"+93\"}, {\"country\": \"Aland Islands\", \"code\": \"+358\"}, {\"country\": \"Albania\", \"code\": \"+355\"}, {\"country\": \"Algeria\", \"code\": \"+213\"}, {\"country\": \"American Samoa\", \"code\": \"+1\"}, {\"country\": \"Andorra\", \"code\": \"+376\"}, {\"country\": \"Angola\", \"code\": \"+244\"}, {\"country\": \"Anguilla\", \"code\": \"+1\"}, {\"country\": \"Antigua & Barbuda\", \"code\": \"+1\"}, {\"country\": \"Argentina\", \"code\": \"+54\"}, {\"country\": \"Armenia\", \"code\": \"+374\"}, {\"country\": \"Aruba\", \"code\": \"+297\"}, {\"country\": \"Australia\", \"code\": \"+61\"}, {\"country\": \"Austria\", \"code\": \"+43\"}, {\"country\": \"Azerbaijan\", \"code\": \"+994\"}, {\"country\": \"Bahamas\", \"code\": \"+1\"}, {\"country\": \"Bahrain\", \"code\": \"+973\"}, {\"country\": \"Bangladesh\", \"code\": \"+880\"}, {\"country\": \"Barbados\", \"code\": \"+1\"}, {\"country\": \"Belarus\", \"code\": \"+375\"}, {\"country\": \"Belgium\", \"code\": \"+32\"}, {\"country\": \"Belize\", \"code\": \"+501\"}, {\"country\": \"Benin\", \"code\": \"+229\"}, {\"country\": \"Bermuda\", \"code\": \"+1\"}, {\"country\": \"Bhutan\", \"code\": \"+975\"}, {\"country\": \"Bolivia\", \"code\": \"+591\"}, {\"country\": \"Bonaire, Sint Eustatius and Saba\", \"code\": \"+599\"}, {\"country\": \"Bosnia & Herzegovina\", \"code\": \"+387\"}, {\"country\": \"Botswana\", \"code\": \"+267\"}, {\"country\": \"Brazil\", \"code\": \"+55\"}, {\"country\": \"British Indian Ocean Territory\", \"code\": \"+246\"}, {\"country\": \"British Virgin Islands\", \"code\": \"+1\"}, {\"country\": \"Brunei\", \"code\": \"+673\"}, {\"country\": \"Bulgaria\", \"code\": \"+359\"}, {\"country\": \"Burkina Faso\", \"code\": \"+226\"}, {\"country\": \"Burundi\", \"code\": \"+257\"}, {\"country\": \"Cambodia\", \"code\": \"+855\"}, {\"country\": \"Cameroon\", \"code\": \"+237\"}, {\"country\": \"Canada\", \"code\": \"+1\"}, {\"country\": \"Cape Verde\", \"code\": \"+238\"}, {\"country\": \"Cayman Islands\", \"code\": \"+1\"}, {\"country\": \"Central African Republic\", \"code\": \"+236\"}, {\"country\": \"Chad\", \"code\": \"+235\"}, {\"country\": \"Chile\", \"code\": \"+56\"}, {\"country\": \"China\", \"code\": \"+86\"}, {\"country\": \"Christmas Island\", \"code\": \"+61\"}, {\"country\": \"Cocos (Keeling) Islands\", \"code\": \"+61\"}, {\"country\": \"Colombia\", \"code\": \"+57\"}, {\"country\": \"Comoros\", \"code\": \"+269\"}, {\"country\": \"Congo\", \"code\": \"+242\"}, {\"country\": \"Cook Islands\", \"code\": \"+682\"}, {\"country\": \"Costa Rica\", \"code\": \"+506\"}, {\"country\": \"Cote d'Ivoire\", \"code\": \"+225\"}, {\"country\": \"Croatia\", \"code\": \"+385\"}, {\"country\": \"Cuba\", \"code\": \"+53\"}, {\"country\": \"Curaçao\", \"code\": \"+599\"}, {\"country\": \"Cyprus\", \"code\": \"+357\"}, {\"country\": \"Czechia\", \"code\": \"+420\"}, {\"country\": \"Democratic Republic of the Congo\", \"code\": \"+243\"}, {\"country\": \"Denmark\", \"code\": \"+45\"}, {\"country\": \"Djibouti\", \"code\": \"+253\"}, {\"country\": \"Dominica\", \"code\": \"+1\"}, {\"country\": \"Dominican Republic\", \"code\": \"+1\"}, {\"country\": \"Ecuador\", \"code\": \"+593\"}, {\"country\": \"Egypt\", \"code\": \"+20\"}, {\"country\": \"El Salvador\", \"code\": \"+503\"}, {\"country\": \"Equatorial Guinea\", \"code\": \"+240\"}, {\"country\": \"Eritrea\", \"code\": \"+291\"}, {\"country\": \"Estonia\", \"code\": \"+372\"}, {\"country\": \"Eswatini\", \"code\": \"+268\"}, {\"country\": \"Ethiopia\", \"code\": \"+251\"}, {\"country\": \"Falkland Islands (Islas Malvinas)\", \"code\": \"+500\"}, {\"country\": \"Faroe Islands\", \"code\": \"+298\"}, {\"country\": \"Fiji\", \"code\": \"+679\"}, {\"country\": \"Finland\", \"code\": \"+358\"}, {\"country\": \"France\", \"code\": \"+33\"}, {\"country\": \"French Guiana\", \"code\": \"+594\"}, {\"country\": \"French Polynesia\", \"code\": \"+689\"}, {\"country\": \"Gabon\", \"code\": \"+241\"}, {\"country\": \"Gambia\", \"code\": \"+220\"}, {\"country\": \"Georgia\", \"code\": \"+995\"}, {\"country\": \"Germany\", \"code\": \"+49\"}, {\"country\": \"Ghana\", \"code\": \"+233\"}, {\"country\": \"Gibraltar\", \"code\": \"+350\"}, {\"country\": \"Greece\", \"code\": \"+30\"}, {\"country\": \"Greenland\", \"code\": \"+299\"}, {\"country\": \"Grenada\", \"code\": \"+1\"}, {\"country\": \"Guadeloupe\", \"code\": \"+590\"}, {\"country\": \"Guam\", \"code\": \"+1\"}, {\"country\": \"Guatemala\", \"code\": \"+502\"}, {\"country\": \"Guernsey\", \"code\": \"+44\"}, {\"country\": \"Guinea\", \"code\": \"+224\"}, {\"country\": \"Guinea-Bissau\", \"code\": \"+245\"}, {\"country\": \"Guyana\", \"code\": \"+592\"}, {\"country\": \"Haiti\", \"code\": \"+509\"}, {\"country\": \"Honduras\", \"code\": \"+504\"}, {\"country\": \"Hong Kong\", \"code\": \"+852\"}, {\"country\": \"Hungary\", \"code\": \"+36\"}, {\"country\": \"Iceland\", \"code\": \"+354\"}, {\"country\": \"India\", \"code\": \"+91\"}, {\"country\": \"Indonesia\", \"code\": \"+62\"}, {\"country\": \"Iraq\", \"code\": \"+964\"}, {\"country\": \"Ireland\", \"code\": \"+353\"}, {\"country\": \"Isle of Man\", \"code\": \"+44\"}, {\"country\": \"Israel\", \"code\": \"+972\"}, {\"country\": \"Italy\", \"code\": \"+39\"}, {\"country\": \"Jamaica\", \"code\": \"+1\"}, {\"country\": \"Japan\", \"code\": \"+81\"}, {\"country\": \"Jersey\", \"code\": \"+44\"}, {\"country\": \"Jordan\", \"code\": \"+962\"}, {\"country\": \"Kazakhstan\", \"code\": \"+7\"}, {\"country\": \"Kenya\", \"code\": \"+254\"}, {\"country\": \"Kiribati\", \"code\": \"+686\"}, {\"country\": \"Kosovo\", \"code\": \"+383\"}, {\"country\": \"Kuwait\", \"code\": \"+965\"}, {\"country\": \"Kyrgyzstan\", \"code\": \"+996\"}, {\"country\": \"Laos\", \"code\": \"+856\"}, {\"country\": \"Latvia\", \"code\": \"+371\"}, {\"country\": \"Lebanon\", \"code\": \"+961\"}, {\"country\": \"Lesotho\", \"code\": \"+266\"}, {\"country\": \"Liberia\", \"code\": \"+231\"}, {\"country\": \"Libya\", \"code\": \"+218\"}]";


        return json_decode($string, true);
    }
}



//Afghanistan (+93)
//Aland lslands (+358)
//Albania (+355)
//Algeria (+213)
//American Samoa (+1)
//Andorra (+376)
//Angola (+244)
//Anguilla (+1)
//Antigua & Barbuda (+1)
//Argentina (+54)
//Armenia (+374)
//Aruba (+297)
//Australia (+61)
//Austria (+43)
//Azerbaijan (+994)
//Bahamas (+1)
//Bahrain (+973)
//Bangladesh (+880)
//Barbados (+1)
//Belarus (+375)
//Belgium (+32)
//Belize (+501)
//Benin (+229)
//Bermuda (+1)
//Bhutan (+975)
//Bolivia (+591)
//Bonaire, Sint Eustatius and Saba (+599)
//Bosnia & Herzegovina (+387)
//Botswana (+267)
//Brazil (+55)
//British Indian Ocean Territory (+246)
//British Virgin lslands (+1)
//Brunei (+673)
//Bulgaria (+359)
//Burkina Faso (+226)
//Burundi (+257)
//Cambodia (+855)
//Cameroon (+237)
//Canada (+1)
//Cape Verde (+238)
//Cayman lslands (+1)
//Central African Republic (+236)
//Chad (+235)
//Chile (+56)China (+86)
//Christmas lsland (+61)
//Cocos (Keeling)lslands (+61)
//Colombia (+57)
//Comoros (+269)
//Congo (+242)
//Cook lslands (+682)
//Costa Rica (+506)
//Cote d'lvoire (+225)
//Croatia (+385)
//Cuba (+53)
//Curaçao (+599)
//Cyprus (+357)
//Czechia (+420)
//Democratic Republic of the Congo (+243)
//Denmark (+45)
//Djibouti (+253)
//Dominica (+1)
//Dominican Republic (+1)
//Ecuador (+593)
//Egypt (+20)El Salvador (+503)
//Equatorial Guinea (+240)
//Eritrea (+291)
//Estonia (+372)
//Eswatini (+268)
//Ethiopia (+251)
//Falkland lslands (lslas Malvinas)(+500)
//Faroe lslands (+298)
//Fii (+679)
//Finland (+358)
//France (+33)
//French Guiana (+594)
//French Polynesia (+689)
//Gabon (+241)
//Gambia (+220)
//Georgia (+995)
//Germany (+49)
//Ghana (+233)
//Gibraltar (+350)
//Greece (+30)
//Greenland (+299)
//Grenada (+1)
//Guadeloupe (+590)
//Guam (+1)
//Guatemala (+502)
//Guernsey (+44)
//Guinea (+224)
//Guinea-Bissau (+245)
//Guyana (+592)
//Haiti (+509)
//Honduras (+504)
//Hong Kong (+852)
//Hungary (+36)
//Iceland (+354)
//India (+91)
//Indonesia (+62)
//lraq (+964)
//Ireland (+353)
//Isle of Man (+44)
//lsrael (+972)
//Italy (+39)
//Jamaica (+1)
//Japan (+81)
//Jersey (+44)
//Jordan (+962)
//Kazakhstan (+7)
//Kenya (+254)
//Kiribati (+686)
//Kosovo (+383)
//Kuwait (+965)
//Kyrgyzstan (+996)
//Laos (+856)
//Latvia (+371)
//Lebanon (+961)
//Lesotho (+266)
//Liberia (+231)
//Libya (+218)
//Liechtenstein (+423)
//Lithuania (+370)
//Luxembourg (+352)
//Macau (+853)
//North Macedonia (+389)
//Madagascar (+261)
//Malawi (+265)
//Malaysia (+60)
//Maldives (+960)
//Mali (+223)
//Malta (+356)
//Marshall lslands (+692)
//Martinique (+596)
//Mauritania (+222)
//Mauritius (+230)
//Mayotte (+262)
//Mexico (+52)
//Micronesia (+691)
//Moldova (+373)
//Monaco (+377)
//Mongolia (+976)
//Montenegro (+382)
//Montserrat (+1)
//Morocco (+212)
//Mozambique (+258)
//Myanmar (+95)
//Namibia (+264)
//Nauru (+674)
//Nepal (+977)
//Netherlands (+31)
//New Caledonia (+687)
//New Zealand (+64)
//Nicaragua (+505)
//Niger (+227)
//Nigeria (+234)
//Niue (+683)
//Norfolk lsland (+672)
//Northern Mariana lslands (+1)
//Norway (+47)
//Oman (+968)
//Pakistan (+92)
//Palau (+680)
//Palestinian Territories (+970)
//Panama (+507)
//Papua New Guinea (+675)
//Paraguay (+595)
//Peru (+51)
//Peru (+51)
//Philippines (+63)
//Pitcairn lslands (+64)
//Poland (+48)
//Portugal (+351)
//Puerto Rico (+1)
//Qatar (+974)
//Réunion (+262)
//Romania (+40)
//Russia (+7)
//Rwanda (+250)
//Samoa (+685)
//San Marino (+378)
//Säo Tomé & Principe (+239)
//Saudi Arabia (+966)
//Senegal (+221)
//Serbia (+381)
//Seychelles (+248)
//Sierra Leone (+232)
//Singapore (+65)
//Sint Maarten (+1)
//Slovakia (+421)
//Slovenia (+386)
//Solomon lslands (+677)
//Somalia (+252)
//South Africa (+27)
//South Georgia & South Sandwich lslands (+50
//South Korea (+82)
//South Sudan (+211)Spain (+34)Sri Lanka (+94)
//St. Barthélemy (+590)
//St. Helena (+290)
//St. Kitts & Nevis (+1)
//St. Lucia (+1)
//St. Martin (+590)
//St. Pierre & Miquelon (+508)
//St. Vincent & Grenadines(+1)
//Sudan (+249)
//Suriname (+597)
//Svalbard & Jan Mayen (+47)
//Sweden (+46)
//Switzerland (+41)
//Taiwan (+886)
//Tajikistan (+992)
//Tanzania (+255)
//Thailand (+66)
//Timor-Leste (+670)
//Togo (+228)
//Tokelau (+690)
//Tonga (+676)
//Trinidad & Tobago (+1)
//Tunisia (+216)
//Turkey (+90)
//Turkmenistan (+993)
//Turks & Caicos lslands (+1)Tuvalu (+688)
//Turks & Caicos lslands (+1)Tuvalu (+688)
//U.S. Virgin lslands (+1)
//Uganda (+256)
//Ukraine (+380)
//United Arab Emirates (+971)
//United Kingdom (+44)
//United States (+1)
//Uruguay (+598)
//Uzbekistan (+998)
//Vanuatu (+678)
//Vatican City (+379)
//Venezuela (+58)
//Vietnam (+84)
//Wallis & Futuna (+681)
//Western Sahara (+212)
//Yemen (+967)
//Zambia (+260)
//Zimbabwe (+263)



